/* ----------------------------------------------------------------------
*
* Copyright (C) 2025 XiaoFei. All rights reserved.
*
* $file:		YeHuo_DS18B20.h
* $Date:        18-March-2025
* $Revision: 	V1
* $Project: 	XiaoFei BSP Library
* $Taobao:      https://item.taobao.com/item.htm?abbucket=17&id=600741703814
*
* -------------------------------------------------------------------- */

#ifndef __YeHuo_DS18B20_H
#define __YeHuo_DS18B20_H

#define DS18B20_RCC_DQ(x) 			    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, (FunctionalState)x)
#define DS18B20_DQ_GPIO					GPIOA
#define DS18B20_DQ_Pin					GPIO_Pin_0
#define DS18B20_DQ(x)					GPIO_WriteBit(DS18B20_DQ_GPIO,DS18B20_DQ_Pin,(BitAction)x)
#define DS18B20_ReadDQ					GPIO_ReadInputDataBit(DS18B20_DQ_GPIO,DS18B20_DQ_Pin)

#ifndef DS18B20_TypeDef_def
#define DS18B20_TypeDef_def
typedef struct
{
	unsigned char DataH ;		/*!< The high data from DS18B20 */
	unsigned char DataL ;		/*!< The low data from DS18B20 */
	unsigned char* ID ;         /*!< The ID of DS18B20 */
	float Temp ;                /*!< The temp data */
}DS18B20_TypeDef;
#endif

/* 
* @function: 	DS18B20_Init
* @parameter:	[in] DS18B20				The Device handle of DS18B20.
* @return:		Return 0x01 if the device is connect.
*/
unsigned char DS18B20_Init(DS18B20_TypeDef* DS18B20);

/* 
* @function: 	DS18B20_Ready
* @parameter:	[in] DS18B20				The Device handle of DS18B20.
*/
void DS18B20_Ready(DS18B20_TypeDef* DS18B20);

/* 
* @function: 	DS18B20_GetData
* @parameter:	[out] DS18B20				The Device handle of DS18B20.
*/
void DS18B20_GetData(DS18B20_TypeDef* DS18B20);

#endif

